package com.taobaolite.demo_item;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(path = "/api/v1/demo_item")
public class DemoItemController {
    private final DemoItemService demoItemService;

    @Autowired
    public DemoItemController(DemoItemService service) {
        this.demoItemService = service;
    }

    @GetMapping(path = "{itemId}")
    public DemoItem getItem(@PathVariable("itemId") Long itemId) {
        return demoItemService.getItem(itemId);
    }

    @GetMapping
    public List<DemoItem> getItems() {
        return demoItemService.getItems();
    }

}
